<?php
	
	/**
	 * undocumented class
	 *
	 * @package default
	 * @author Brian Bal
	 **/
	class ScaffoldingGenerator Extends BaseGenerator
	{
		
		public function generate($params)
		{
			if(isset($params[3]))
			{
				$this->model_name = $params[2];
				$this->controller_name = $params[3];
			}else{
				printUsage();
				exit();
			}
			
			$this->generateModel();
			$this->generateController();
		}
		
		public function generateModel()
		{
			echo "starting generateModel()\n";
			// generate the model file
			$this->model_name = ucfirst($this->model_name);
			$this->model_tn = uncamelize($this->model_name);
			$this->model_tn_plural = plural($this->model_tn);
			$this->model_hn = humanize($this->model_tn);
			
			$filename = PROJECT_DIR . "app/models/$this->model_tn.php";
			$model_content = $this->renderFile(PROJECT_DIR . "scripts/generators/Scaffolding/templates/model.php");
			$this->writeFile($filename, $model_content);
		}
		
		public function generateController()
		{
			// generate the Controller file
			$this->controller_tn = strtolower($this->controller_name);
			$this->controller_name = ucfirst($this->controller_name) . "_Controller";
			$this->controller_hn = humanize($this->controller_tn);
			$filename = PROJECT_DIR . "app/controllers/$this->controller_tn.php";
			$content = $this->renderFile(PROJECT_DIR . "scripts/generators/Controller/templates/controller.php");
			$this->writeFile($filename, $content);
			
			// generate the view directory for this controller
			$this->createFolder(PROJECT_DIR . "app/views/$this->controller_tn");
			
			// generate the index view
			//$filename = PROJECT_DIR . "app/views/$this->controller_tn/index.html";
			//$content = $this->renderFile(PROJECT_DIR . "scripts/generators/Controller/templates/index_view.php");
			//$this->writeFile($filename, $content);
		}
		
	} // END class 